import { Cli } from 'clipanion'

import { BundleCommand } from './bundle'
import { E2ECommand } from './e2e'
import { GenerateLicenseCommand } from './generate-license'
import { IdlCommand } from './idl'
import { SCMCommand } from './scm'

const cli = new Cli({
  binaryLabel: 'Maiev dev',
  binaryName: `bin`,
  binaryVersion: `0.0.0`,
})

cli.register(BundleCommand)
cli.register(E2ECommand)
cli.register(IdlCommand)
cli.register(SCMCommand)
cli.register(GenerateLicenseCommand)

cli
  .run(process.argv.slice(2), {
    stdin: process.stdin,
    stdout: process.stdout,
    stderr: process.stderr,
  })
  .then((code) => {
    process.exit(code)
  })
  .catch((e) => {
    console.error(e)
    process.exit(1)
  })
